rnorm(10) # draw 10 random values from a Standard Normal distribution [1] 0.4505376 -0.5388416 0.3402315 -0.9043802 -0.1552104 1.8460130
[7] -1.1469020 -0.5383153 1.1677107 -0.7632631
Mainstream in academia for data science, increasingly used in business. Job market advantage!
Free & open-source: wherever you go, R will be with you at no costs (unlike SPSS, MPLUS, MATLAB, etc.)
Real programming language: difficult at the beginning? but: 1) gives you lots of flexibility; 2) facilitates learning any other programming language (e.g., Python).
Vast community support thanks to a large and active community (also, chatGPT knows it pretty well!).
Huge ecosystem, >20,000 packages on CRAN, more from other sources (e.g., GitHub), to do amazing stuff with statistical data analysis, machine learning, data visualization, developing webapps [shiny], writing reports and even entire books [bookdown, rmarkdown]), can integrate with quarto, github.
Facilitates reproducible research by sharing code and workflows.
Executing fundamental operations and using basic functions in R;
working with essential data types and structures;
Gaining some proficiency in managing and manipulating data with vectors and dataframes;
Understanding some fundamental concepts of programming.
Core statistical inference methods;
(Generalized) linear (mixed-effects) modeling;
Data visualization using ggplot2;
Power analysis via data simulation ;
Structural Equation Modeling;
Conducting meta-analysis.
see Shiny gallery
here’s a couple of recent real examples from Psicostat members:
this game-like shiny app developed for the science4all event in Padova; see here some explanation in Italian
practical ad-hoc shiny app for scoring experimental data collected by students
this entire course is a website in its own right
the course textbook is a book/website
also see this wonderful book by Daniël Lakens explaining Statistical Inference
of course, these resources integrate other tools such as GitHub and Quarto, but they can be created within the R ecosystem
first of all, for getting started, follow the instructions in Chapter 1 of Introduction2R to ensure that both R and RStudio are installed
| Package | Used for what | Example(s) of functions |
|---|---|---|
base (base R) |
Basic functions | sum, mean, sqrt, abs, c, data.frame, summary, plot, +, - |
stats (base R) |
Basic statistical calculations and functions | sd, cor, cor.test, t.test, lm, glm, AIC, rnorm, rbinom |
graphics (base R) |
Basic statistical calculations and functions | boxplot, hist, barplot |
effectsize |
Compute different effect sizes | cohens_d, hedges_g, cohens_f, d_to_r |
| Package | Used for what | Example(s) of functions |
|---|---|---|
lme4 |
Fitting (generalized) (non-)linear mixed-effects models | lmer, glmer, ranef |
performance |
Useful tools for models | check_collinearity, r2_nagelkerke, icc |
effects |
Display effects for various statistical models | allEffects |
emmeans |
Estimate marginal means for various models | emmeans |
ggplot2 |
Create beautiful plots using The Grammar of Graphics | ggplot, geom_* |
| Package | Used for what | Example(s) of functions |
|---|---|---|
lavaan |
Structural equation modeling (SEM) | cfa, sem |
semTools |
Useful tools for SEMs | reliability |
metafor |
Perform meta-analysis | rma, rma.mv, forest, funnel, regtest |
brms |
Fitting practically any Bayesian model via MCMC with STAN | brm, prior |
blavaan |
Fitting Bayesian SEMs | bcfa, bsem |
Let’s run a few commands in RStudio to familiarize with its console and see if the installation works properly
[1] 0.4505376 -0.5388416 0.3402315 -0.9043802 -0.1552104 1.8460130
[7] -1.1469020 -0.5383153 1.1677107 -0.7632631
[1] 100 104 85 87 91 126 101 104 70 74
library(psych) # load the newly installed package
fisherz(rho=0.9) # use it to transform a correlation into a Fisher's z[1] 1.472219